<%@ page contentType="text/html;charset=UTF-8"  language="java" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.utils.SystemProperty" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>Hello App Engine</title>
  </head>

  <body>
    <h1>Hello App Engine!</h1>
	
    <table>
      <tr>
        <td colspan="2" style="font-weight:bold;">Available Servlets:</td>        
      </tr>
<%
		boolean debug = (SystemProperty.environment.value() == SystemProperty.Environment.Value.Development);
		UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();
        if ((user != null && "leeon.liu@gmail.com".equalsIgnoreCase(user.getEmail()))
        	|| debug) {
%>      
      <tr>
        <td><b>admin board</b></td>
      </tr>
      <tr>
        <td><a href="bbscache/refreshAll">refresh all(fetch board from network)</a></td>
      </tr>
      <tr>
        <td><a href="bbscache/refreshTotal">refresh board total(fetch total from db)</a></td>
      </tr>
      <tr>
        <td><a href="bbscache/refreshAllFromDb">refresh all(fetch board from db)</a></td>
      </tr>
      <tr>
        <td><a href="bbscache/printBoard">print all board, block and top ten cache</a></td>
      </tr>
      <tr>
        <td><b>doc all cache</b></td>
      </tr>
      <tr>
        <td><a href="bbscache/clearNewDocCache">clear doc new cache</a></td>
      </tr>
      <tr>
        <td><a href="bbscache/clearIndexCache">clear offset index cache</a></td>
      </tr>
      <tr>
        <td><a href="bbscache/printNewDocCache">print doc new cache</a></td>
      </tr>
      <tr>
        <td><a href="bbscache/printIndexCache">print offset index cache</a></td>
      </tr>
      <tr>
        <td><b>doc board</b></td>
      </tr>
      <tr>
        <td><a href="queue/queueBoard?board=">add queue refresh board</a></td>
      </tr>
      <tr>
        <td><a href="queue/queueDelete?board=">add queue delete board</a></td>
      </tr>
      <tr>
        <td><a href="queue/clearBoardEntity?board=">clear board doc entity</a></td>
      </tr>
      <tr>
        <td><b>all board</b></td>
      </tr>
      <tr>
        <td><a href="bbscache/clearEntity">clear all doc entity</a></td>
      </tr>
      <tr>
        <td><a href="bbscache/clearPicture">clear all picture</a></td>
      </tr>
      <tr>
        <td><a href="queue/refreshBoard">refresh board</a></td>
      </tr>
      <tr>
        <td><a href="queue/deleteBoard">delete board</a></td>
      </tr>
      <tr>
        <td><a href="queue/refreshTopTen">refresh top ten</a></td>
      </tr>
      <tr>
        <td><b>test</b></td>
      </tr>
      <tr>
        <td><a href="bbscache/test">test</a></td>
      </tr>
<%
} else if (user == null) {
	response.sendRedirect(userService.createLoginURL(request.getRequestURI()));
}
%>
    </table>
  </body>
</html>
